VFG.Listener=function(viewer,option){
	this.option = Cesium.defaultValue(option, Cesium.defaultValue.EMPTY_OBJECT);
	if (!option) {
		console.log('参数必填!');
		return;
	}
	if (!viewer) {
		console.log('参数必填!');
		return;
	}
	
	this.position = option.position;
	if(!this.position){
		console.log('参数必填!');
		return;
	}
	this.option = option;
	this.viewer = viewer;
	this.position = Cesium.Cartesian3.fromDegrees(option.position.x*1, option.position.y*1, option.position.z*1);
	this.callback = option.callback;
	this.init();
}

/**
 * 初始化
 */
VFG.Listener.prototype.init=function(){
	var _this=this;
	if(_this.position){
		_this.event=function(){
			var cartesian2=Cesium.SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, _this.position);
			if (Cesium.defined(cartesian2)){
				if(_this.callback){
					_this.callback(cartesian2);
				}
			}
		}
		_this.viewer.scene.postRender.addEventListener(_this.event);
	}else{
		console.log('初始化失败，检测是否有效经纬度!!!');
	}
}

/**
 * 销毁
 */
VFG.Listener.prototype.destroy=function(){
	var _this = this;
	if(_this.event){
		_this.viewer.scene.postRender.removeEventListener(_this.event);
	}
	_this.event=null;
	delete this.option,
	delete this.callback,
	delete this.viewer,
	delete this.position;
	delete this.event;
	return Cesium.destroyObject(this);
}
